#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 2e5 + 10;

int n;
struct Segment
{
    int x, y1, y2, k;
    bool operator< (const Segment& W)const{
        return x < W.x;
    }
}seg[N * 2];
struct Node
{
    int l, r;
    int cnt, sum;
}node[N * 8];
vector<int> nums;

int find(int x){
    return lower_bound(nums.begin(), nums.end(), x) - nums.begin();
}

void pushup(int u){
    if(node[u].cnt > 0){
        node[u].sum = nums[node[u].r + 1] - nums[node[u].l];
    }else{
        node[u].sum = node[u << 1].sum + node[u << 1 | 1].sum;
    }
}


void build(int u, int l, int r){
    node[u].l = l, node[u].r = r, node[u].cnt = 0, node[u].sum = 0;
    if(l == r) return;
    int mid = l + r >> 1;
    build(u << 1, l, mid), build(u << 1 | 1, mid + 1, r);
}

void modify(int u, int l, int r, int k){
    if(node[u].l >= l && node[u].r <= r){
        node[u].cnt += k;
        pushup(u);
    }else{
        int mid = node[u].l + node[u].r >> 1;
        if(l <= mid) modify(u << 1, l, r, k);
        if(r > mid) modify(u << 1 | 1, l, r, k);
        pushup(u);
    }
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    scanf("%d", &n);
    for(int i = 0, j = 0; i < n; i ++){
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        seg[j ++] = {x1, y1, y2, 1};
        seg[j ++] = {x2, y1, y2, -1};
        nums.push_back(y1);
        nums.push_back(y2);
    }

    sort(nums.begin(), nums.end());
    nums.erase(unique(nums.begin(), nums.end()), nums.end());

    sort(seg, seg + n * 2);

    build(1, 0, nums.size() - 2);

    LL res = 0;
    for(int i = 0; i < n * 2; i ++){
        if(i > 0){
            res = (LL) res + (LL)node[1].sum * (seg[i].x - seg[i - 1].x);
        }

        modify(1, find(seg[i].y1), find(seg[i].y2) - 1, seg[i].k);
    }

    printf("%lld\n", res);

    return 0;
}